<?php
/**
 * Created by PhpStorm.
 * User: jieaido
 * Date: 2017/4/12
 * Time: 8:45
 */
namespace Home\Controller;
use Think\Controller;
use Think\Model;

class GsvalueController extends MyController{
    public function index()
    {
        $this->display();
    }

    public function getlist()
    {

        $this->Checklogin();
        //region 默认时间为最近一个月
        $stime=strtotime(I('stime',date('Y-M-d ',time()-60*60*24*31)));
        $dtime=strtotime(I('dtime',date('Y-M-d',time())));
        //endregion

        $result=new \Think\Model();
        $db=$result->query("SELECT a.id,a.name,b.gsrecord_id,b.gsvalue ,sum(b.gsvalue) AS  gsvalue,c.starttime FROM gs_member as a
LEFT JOIN gs_member_gsrecord  AS b ON a.id=b.member_id
LEFT JOIN gs_gsrecord as c ON c.id=b.gsrecord_id
WHERE c.starttime BETWEEN $stime AND $dtime AND c.pend=1 AND c.status=0
GROUP BY a.id ORDER BY gsvalue DESC;");
     $this->ajaxReturn($db);
    }

}